package self.hoy.demo.grainmall.cart.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import self.hoy.demo.grainmall.cart.interceptor.CartInterceptor;

/**
 * @author hyh
 * @date 2020/8/16
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    @Value("${site.domain}")
    private String domain;

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/success.html").setViewName("success");
//        registry.addViewController("/cartList.html").setViewName("cartList");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CartInterceptor(domain)).addPathPatterns("/**");
    }
}
